fix(server): eliminate startup panics and add pub/sub pattern length cap - #179
Merged
Conversation
…Result ClusterCoordinator::new and from_config now return Err instead of panicking when port + offset overflows u16. callers in main.rs use exit_err as with all other startup errors. also adds psubscribe pattern length cap (512 bytes) as defense in depth behind the existing 256-byte check in the connection handler. psubscribe now returns Option<Receiver> so invalid patterns are rejected at the API level. fixes ttl overflow in concurrent_handler pttl: multiply within u64 domain before casting to i64.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
summary
three security fixes in ember-server found during the pre-merge audit:
port overflow panic —
ClusterCoordinator::newandfrom_configboth called.expect()on achecked_addfor the gossip port, which would panic at startup if the port offset caused a u16 overflow. both now returnResultso callers can handle the error withexit_err.pub/sub pattern length cap —
psubscribenow returnsOption<Receiver>and rejects patterns longer than 512 bytes. the connection handler already had a 256-byte check; this adds defense-in-depth at the API level so direct callers are also protected.PTTL millisecond overflow —
s as i64 * 1000in the concurrent handler would overflow for TTL values > ~9.2×10^15 seconds. fixed by multiplying within u64 and capping ati64::MAXbefore the cast.also includes the workspace-wide
cargo fmt+cargo clippypass as the first commit.what was tested
cargo clippy --workspace --all-features -- -D warningscleancargo test -p ember-server— 56 tests pass including:cluster::tests::new_rejects_port_overflow(new)pubsub::tests::psubscribe_rejects_oversized_pattern(new)cargo test --workspace --lib— 337 unit tests pass